/**
 * Copyright (C) 2010 Lynx S.p.A. <lucio.benfante@gmail.com>
 *
 * This file is part of Ternion Web Application.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.lynxspa.ternion.web.beans;

import java.util.LinkedList;
import java.util.List;
import org.parancoe.plugins.security.User;
import org.springmodules.validation.bean.conf.loader.annotation.handler.CascadeValidation;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Expression;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Length;
import org.springmodules.validation.bean.conf.loader.annotation.handler.Validator;

/**
 * A bean for editing a user.
 *
 * @author Lucio Benfante
 */
@Validator(value = UserBeanAuthoritiesValidator.class)
public class UserBean {

    @CascadeValidation
    private User user;
    @Length(min = 4, max = 40, applyIf = "newPassword != ''")
    private String newPassword;
    @Expression("confirmPassword == newPassword")
    private String confirmPassword;
    List<AuthorityCheckBox> authorityCheckBoxes = new LinkedList<AuthorityCheckBox>();

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public String getNewPassword() {
        return newPassword;
    }

    public void setNewPassword(String newPassword) {
        this.newPassword = newPassword;
    }

    public String getConfirmPassword() {
        return confirmPassword;
    }

    public void setConfirmPassword(String confirmPassword) {
        this.confirmPassword = confirmPassword;
    }

    public List<AuthorityCheckBox> getAuthorityCheckBoxes() {
        return authorityCheckBoxes;
    }

    public void setAuthorityCheckBoxes(List<AuthorityCheckBox> authorityCheckBoxes) {
        this.authorityCheckBoxes = authorityCheckBoxes;
    }
}
